<template>
  <div>
    <div class="title">{{ this.qyObj && this.qyObj.name }}</div>
    <van-collapse v-model="activeName">
      <van-collapse-item title="基本信息" name="1">
        <template #value>
          <div>
            <span class="tag tag2">园区数据</span>
          </div>
        </template>
        <div class="table">
          <div v-for="(item, index) in baseInfo" :key="index">
            <div class="tr bg-g" v-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '企业背调')"
        title="企业背调"
        name="2"
      >
        <template #value>
          <div>
            <span class="tag tag1">同花顺</span>
          </div>
        </template>
        <div class="table">
          <div v-for="(item, index) in businessList" :key="index">
            <div class="tr bg-g" v-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '知识产权')"
        title="知识产权"
        name="3"
      >
        <template #value>
          <div>
            <span class="tag tag3">市场监管</span>
          </div>
        </template>
        <div class="table">
          <div v-for="(item, index) in zscqList" :key="index">
            <div class="tr bg-g" v-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '营收信息')"
        title="营收信息"
        name="4"
      >
        <template #value>
          <div>
            <span class="tag tag3">市场监管</span>
          </div>
        </template>
        <van-field
          readonly
          clickable
          name="datetimePicker"
          :value="revenueDateValue"
          label="月份选择"
          placeholder="点击选择月份"
          @click="revenueDatetimePickerShowPicker = true"
        />
        <van-popup v-model="revenueDatetimePickerShowPicker" position="bottom">
          <van-datetime-picker
            v-model="currentDate"
            type="year-month"
            @confirm="dateConfirm"
            @cancel="revenueDatetimePickerShowPicker = false"
          />
        </van-popup>
        <div class="table">
          <div v-for="(item, index) in revenueYSList" :key="index">
            <div class="tr bg-g" v-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '税务信息')"
        title="税务信息"
        name="5"
      >
        <template #value>
          <div>
            <span class="tag tag3">市场监管</span>
          </div>
        </template>
        <van-field
          readonly
          clickable
          name="datetimePicker"
          :value="taxDateValue"
          label="月份选择"
          placeholder="点击选择月份"
          @click="taxDatetimePickerShowPicker = true"
        />
        <van-popup v-model="taxDatetimePickerShowPicker" position="bottom">
          <van-datetime-picker
            v-model="currentDate"
            type="year-month"
            @confirm="taxDateConfirm"
            @cancel="taxDatetimePickerShowPicker = false"
          />
        </van-popup>
        <div class="table">
          <div v-for="(item, index) in taxList" :key="index">
            <div class="tr bg-g" v-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '发票信息')"
        title="发票信息"
        name="6"
      >
        <template #value>
          <div>
            <span class="tag tag4">财税云</span>
          </div>
        </template>
        <div class="table">
          <div v-for="(item, index) in invoiceList" :key="index">
            <div class="tr bg-g" v-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '社保信息')"
        title="社保信息"
        name="7"
      >
        <div>暂无数据</div>
        <template #value>
          <div>
            <span class="tag tag3">市场监管</span>
          </div>
        </template>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '用能信息')"
        title="用能信息"
        name="8"
      >
        <template #value>
          <div>
            <span class="tag tag2">园区数据</span>
          </div>
        </template>
        <van-field
          readonly
          clickable
          name="datetimePicker"
          :value="yongnengDateValue"
          label="月份选择"
          placeholder="点击选择月份"
          @click="yongnengDatetimePickerShowPicker = true"
        />
        <van-popup v-model="yongnengDatetimePickerShowPicker" position="bottom">
          <van-datetime-picker
            v-model="currentDate"
            type="year-month"
            @confirm="yongnengDateConfirm"
            @cancel="yongnengDatetimePickerShowPicker = false"
          />
        </van-popup>
        <div class="table">
          <div v-for="(item, index) in revenueList" :key="index">
            <div class="tr bg-g" v-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '人员信息')"
        title="人员信息"
        name="9"
      >
        <template #value>
          <div>
            <span class="tag tag2">园区数据</span>
          </div>
        </template>
        <div class="table">
          <!-- <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
          > -->
          <div v-if="!personList.length">暂无数据</div>
          <div v-for="(item, index) in personList" :key="index">
            <div v-if="item.name == '序号'">人员{{ item.num }}</div>
            <div class="tr bg-g" v-else-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
          <!-- </van-list> -->
        </div>
      </van-collapse-item>
      <van-collapse-item
        v-if="permissList.find((x) => x == '入驻信息')"
        title="入驻信息"
        name="10"
      >
        <template #value>
          <div>
            <span class="tag tag2">园区数据</span>
          </div>
        </template>
        <div class="table">
          <div v-for="(item, index) in settlementInfo" :key="index">
            <div v-if="item.name == '序号'">空间{{ item.num }}</div>
            <div class="tr bg-g" v-else-if="index % 2 == 0">
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
            <div class="tr" v-else>
              <div class="td">{{ item.name }}</div>
              <div class="td">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </van-collapse-item>
    </van-collapse>
  </div>
</template>

<script>
import { formatDate } from "@/assets/js/common.js";
export default {
  data() {
    return {
      id: "",
      activeName: ["1"],
      qyObj: {},
      revenueDatetimePickerShowPicker: false,
      taxDatetimePickerShowPicker: false,
      yongnengDatetimePickerShowPicker: false,
      revenueDateValue: "",
      taxDateValue: "",
      yongnengDateValue:'',
      currentDate: new Date(),
      // 企业注册信息
      register: {},
      // 企业情况
      situation: {},
      // 人员总览
      personnelOverview: {},
      // 培育计划
      cultivation: {},
      baseInfo: [
        // { text: "企业名称", value: "浙江润湾投资有限公司" },
        // { text: "企业类型", value: "有限责任公司" },
        // { text: "企业状态", value: "存续" },
        // // {  text: "企业规模", value:"12312" },
        // // {  text: "经营执照", value:"12312" },
        // { text: "统一信用代码", value: "91330900MA2A3K289U" },
        // { text: "注册号", value: "3300000000275145" },
        // // {  text: "法人身份证", value:"12312" },
        // { text: "法人名称", value: "程小明" },
        // { text: "登记机关", value: "浙江省市场监督管理局" },
        // { text: "成立日期", value: "1994-07-08" },
        // { text: "省份", value: "ZJ" },
        // { text: "更新日期", value: "2020-07-07 17:30:07" },
        // {  text: "联系方式", value:"12312" },
        // {  text: "电子邮箱", value:"12312" },
      ],
      business: {},
      // 企业背调列表
      businessList: [],
      qiyebeidiaoData:{},
      // 税务信息
      taxList: [],
      // 发票信息
      invoiceList: [],
      // settlement:[],
      // 人员信息
      personList: [],
      personListNum: 0,
      loading: false,
      finished: false,
      personListQueryData: {
        pageNo: 1,
        pageSize: 10,
      },
      // 入驻信息
      settlementInfo: [],
      // 用能信息
      revenueList: [],
      revenueYSList: [],
      // 知识产权
      zscqList: [],
    };
  },
  created() {
    this.id = this.$route.query.id;
    this.enterpriseGet();
    this.getInvoice();
    this.getSettlement();
    this.revenueDateValue = formatDate("YY-MM", new Date());
    this.revenueDateValue = this.getPreMonth(this.revenueDateValue);
    this.taxDateValue = formatDate("YY-MM", new Date());
    this.taxDateValue = this.getPreMonth(this.taxDateValue);
  },
  methods: {
    getPreMonth(value) {
      let arr = value.split("-");
      if (arr[1] == "01") {
        arr[1] = "12";
        arr[0]--;
      } else {
        arr[1]--;
        (arr[1] + "").length == 1 ? (arr[1] = "0" + arr[1]) : (arr[1] = arr[1]);
      }
      return arr.join("-");
    },
    enterpriseGet() {
      this.$api
        .enterprise({ method: "post", type: "get" }, { id: this.id })
        .then((res) => {
          if (res.data.isSuccess) {
            this.qyObj = res.data.data;
            this.getRevenue();
            this.getTax();
            this.getPersonnel();
            console.log("res.data.data", res.data.data);
            // 企业信息
            this.register = this.qyObj.register;
            this.situation = this.qyObj.situation;
            this.personnelOverview = this.qyObj.personnelOverview;
            this.cultivation = this.qyObj.cultivation;
            // 企业注册信息
            this.baseInfo.push(
              {
                name: "企业注册地址",
                num:
                  this.qyObj.register && this.qyObj.register.registeredAddress,
              },
              {
                name: "实际办公地址",
                num: this.qyObj.register && this.qyObj.register.physicalAddress,
              },
              {
                name: "两址合一",
                num: this.qyObj.register && this.qyObj.register.twoSites,
              },
              {
                name: "入驻性质",
                num:
                  this.qyObj.register && this.qyObj.register.natureSettlement,
              },
              {
                name: "税是否缴纳在五常",
                num: this.qyObj.register && this.qyObj.register.taxPlace,
              },
              {
                name: "入驻面积",
                num: this.qyObj.register && this.qyObj.register.settlementArea,
              }
            );
            // 企业情况
            this.baseInfo.push(
              {
                name: "是否上市",
                num: this.qyObj.situation && this.qyObj.situation.islisted,
              },
              {
                name: "是否规上",
                num: this.qyObj.situation && this.qyObj.situation.isqualified,
              },
              {
                name: "是否市高",
                num: this.qyObj.situation && this.qyObj.situation.iscityHigh,
              },
              {
                name: "是否国高",
                num: this.qyObj.situation && this.qyObj.situation.isoverDraf,
              }
            );
            // 人员总览
            this.baseInfo.push(
              {
                name: "职工人数",
                num:
                  this.qyObj.personnelOverview &&
                  this.qyObj.personnelOverview.workersNum,
              },
              {
                name: "党员人数",
                num:
                  this.qyObj.personnelOverview &&
                  this.qyObj.personnelOverview.partyMemberNum,
              }
            );
            // 人才统计
            this.baseInfo.push(
              {
                name: "领军",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.lj,
              },
              {
                name: "A类",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.al,
              },
              {
                name: "B类",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.bl,
              },
              {
                name: "C类",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.cl,
              },
              {
                name: "D类",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.dl,
              },
              {
                name: "E类",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.el,
              },
              {
                name: "F类",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.fl,
              },
              {
                name: "博士/高级职称",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.bs,
              },
              {
                name: "硕士/研究生",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.ssyjs,
              },
              {
                name: "本科",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.bk,
              },
              {
                name: "研发人员",
                num:
                  this.qyObj.personnelStatistics &&
                  this.qyObj.personnelStatistics.yf,
              }
            );
            this.cultivation = this.qyObj.cultivation;
            // 产品信息
            this.baseInfo.push(
              { name: "主要产品", num: this.qyObj.zycp },
              { name: "研发产品", num: this.qyObj.yfcp }
            );
            // 培育计划
            this.baseInfo.push(
              {
                name: "国高",
                num: this.cultivation && this.cultivation.countryHight,
              },
              {
                name: "雏鹰青蓝",
                num: this.cultivation && this.cultivation.cyql,
              },
              { name: "鲲鹏", num: this.cultivation && this.cultivation.kp },
              { name: "上市", num: this.cultivation && this.cultivation.list }
            );
            // // 入驻信息
            // this.settlementInfo.push(
            //   { name: "场地名称", num: this.qyObj.settlement.siteName },
            //   { name: "场地类型", num: this.qyObj.settlement.siteType },
            //   { name: "场地位置", num: this.qyObj.settlement.siteArea },
            //   {
            //     name: "租赁面积(平方米)",
            //     num: this.qyObj.settlement.rentArea,
            //   },
            //   {
            //     name: "面积单价(元/平方/天)",
            //     num: this.qyObj.settlement.areaPrice,
            //   }
            // );
            // 企业背调
            // this.business = this.qyObj.business;
            // this.businessList.push(
            //   { name: "企业全称", num: this.qyObj && this.qyObj.name },
            //   {
            //     name: "社会统一信用代码",
            //     num: this.qyObj && this.qyObj.credit_no,
            //   },
            //   {
            //     name: "注册号",
            //     num: this.business && this.business.registrationNum,
            //   },
            //   {
            //     name: "曾用名",
            //     num: this.business && this.business.beforeName,
            //   },
            //   { name: "登记机关", num: this.business && this.business.djjg },
            //   {
            //     name: "法人名称",
            //     num: this.business && this.business.legalPersonName,
            //   },
            //   {
            //     name: "成立日期",
            //     num: this.business && this.business.establishmentString,
            //   },
            //   {
            //     name: "吊销日期",
            //     num: this.business && this.business.revocationString,
            //   },
            //   { name: "企业状态", num: this.business && this.business.state },
            //   { name: "省份", num: this.business && this.business.province },
            //   { name: "更新日期", num: this.business && this.business.gxrq },
            //   {
            //     name: "注册资本",
            //     num: this.business && this.business.registeredCapital,
            //   },
            //   { name: "企业类型", num: this.business && this.business.type },
            //   { name: "地址", num: this.business && this.business.adress },
            //   {
            //     name: "经营范围",
            //     num: this.business && this.business.businessScope,
            //   },
            //   {
            //     name: "营业开始日期",
            //     num: this.business && this.business.yyksrq,
            //   },
            //   {
            //     name: "营业结束日期",
            //     num: this.business && this.business.yyjsrq,
            //   },
            //   { name: "发照日期", num: this.business && this.business.fzrq },
            //   {
            //     name: "组织机构代码",
            //     num: this.business && this.business.organizationCode,
            //   },
            //   { name: "是否上市", num: this.business && this.business.isList }
            //   // { name: "企业logo", num: "this.business&&this.business.LogoFileId" },
            // );
            this.business = this.qyObj.business;
            this.$api.enterprise({ method: "post", type: "getTHStoken" })
            .then((res) => {
              const token = 'Bearer'+res.data.data.access_token
              if(this.qyObj.credit_no){
                this.$api.enterprise({ method: "post", type: "getTHSQYXX" },{code:this.qyObj.credit_no,token})
                  .then((res) => {
                    console.log('getTHSQYXX',res);
                    this.qiyebeidiaoData = res.data.data
                    this.businessList.push(
                      { name: "企业全称", num: this.qyObj && this.qyObj.name },
                      {
                        name: "社会统一信用代码",
                        num: this.qyObj && this.qyObj.credit_no,
                      },
                      {
                        name: "注册号",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.reg_num,
                      },
                      {
                        name: "曾用名",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.used_name,
                      },
                      { name: "登记机关", num: this.qiyebeidiaoData&&this.qiyebeidiaoData.record_authority },
                      {
                        name: "法人名称",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.legal_representative,
                      },
                      {
                        name: "成立日期",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.established_date,
                      },
                      {
                        name: "吊销日期",
                        num: '',
                      },
                      { name: "企业状态", num: this.qiyebeidiaoData&&this.qiyebeidiaoData.operating_status },
                      { name: "省份", num: this.qiyebeidiaoData&&this.qiyebeidiaoData.province },
                      { name: "更新日期", num: '' },
                      {
                        name: "注册资本",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.reg_capital,
                      },
                      { name: "企业类型", num: this.qiyebeidiaoData&&this.qiyebeidiaoData.corp_type },
                      { name: "地址", num: this.qiyebeidiaoData&&this.qiyebeidiaoData.corp_address },
                      {
                        name: "经营范围",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.operating_scope,
                      },
                      {
                        name: "营业开始日期",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.operating_dur.split('至')[0],
                      },
                      {
                        name: "营业结束日期",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.operating_dur.split('至')[1],
                      },
                      { name: "发照日期", num: this.qiyebeidiaoData&&this.qiyebeidiaoData.issue_date },
                      {
                        name: "组织机构代码",
                        num: this.qiyebeidiaoData&&this.qiyebeidiaoData.org_code,
                      },
                      { name: "是否上市", num: '' }
                      // { name: "企业logo", num: "this.business&&this.business.LogoFileId" },
                    );
                    console.log('businessList',this.businessList)
                  })
              }
            })
            this.zscqList.push(
              {
                name: "证书数量",
                num:
                  this.qyObj.floatellectual &&
                  this.qyObj.floatellectual.certificatesNum,
              },
              {
                name: "作品著作权数量",
                num:
                  this.qyObj.floatellectual &&
                  this.qyObj.floatellectual.copyrightNum,
              },
              {
                name: "软著数量",
                num:
                  this.qyObj.floatellectual &&
                  this.qyObj.floatellectual.softWritingNum,
              },
              {
                name: "专利数量",
                num:
                  this.qyObj.floatellectual &&
                  this.qyObj.floatellectual.patentNum,
              },
              {
                name: "商标数量",
                num:
                  this.qyObj.floatellectual &&
                  this.qyObj.floatellectual.trademarkNum,
              },
              {
                name: "网站信息数量",
                num:
                  this.qyObj.floatellectual &&
                  this.qyObj.floatellectual.websiteNum,
              }
            );
            // // this.revenue = this.qyObj.revenue
            // this.settlement.push({
            //   siteName:this.qyObj.settlement.siteName,
            //   siteType:this.qyObj.settlement.siteType,
            //   siteArea:this.qyObj.settlement.siteArea,
            //   rentalArea:this.qyObj.settlement.rentalArea,
            //   areaPrice:this.qyObj.settlement.areaPrice,
            //   qdrq:this.qyObj.settlement.qdrq,
            //   zzrq:this.qyObj.settlement.zzrq,
            // })
          }
          console.log(" this.register ", this.register);
        })
        .catch(function (error) {});
    },
    // 发票信息
    getInvoice() {
      this.$api
        .settlement({ method: "post", type: "datagrid" }, { id: this.id })
        .then((res) => {
          console.log("--发票信息-", res);
          var data = res.data.data[0];
          this.invoiceList.push(
            { name: "发票代码", num: data.code },
            { name: "发票号", num: data.num },
            { name: "开票日期", num: data.kprq },
            { name: "销方名称", num: data.sellerName },
            { name: "销方税号", num: data.sellerTaxNum },
            { name: "销方地址", num: data.sellerAdress },
            { name: "销方银行账号", num: data.sellerBankCode },
            { name: "合计金额", num: data.totalAmount },
            { name: "合计税额", num: data.totalTax },
            { name: "价税合计", num: data.jshj },
            { name: "价备注税合计", num: data.remark },
            { name: "作废标志", num: data.voidMark },
            { name: "行号", num: data.lineNum },
            { name: "产品名称", num: data.productName },
            { name: "产品型号", num: data.productModel },
            { name: "计量单位", num: data.company },
            { name: "数量", num: data.number },
            { name: "单价", num: data.unitPrice },
            { name: "不含税金额", num: data.bhsje },
            { name: "税率", num: data.taxRate }
          );
        });
    },
    // 人员信息
    getPersonnel() {
      this.$api
        .personnel(
          { method: "post", type: "getPeopleByEnCode" },
          { enCode: this.qyObj.code }
        )
        .then((res) => {
          var data = res.data.data;
          data.forEach((item, index) => {
            this.personListNum++;
            this.personList.push(
              { name: "序号", num: index + 1 },
              { name: "人员姓名", num: item.name },
              { name: "联系方式", num: item.phone },
              { name: "电子邮箱", num: item.email },
              { name: "身份证号", num: item.cardNum }
            );
          });
          // if (this.personListNum == res.data.total)
          //       return (this.finished = true);
          //     this.queryData.pageNo++;
          //     this.loading = false;
        });
    },
    onLoad() {
      this.getPersonnel();
    },
    // 营收信息
    getRevenue(flag) {
      let queryData = {
        pageNo: 1,
        pageSize: 10000,
        // enterpriseId: this.id,
        enCode: this.qyObj.credit_no,
        date: this.revenueDateValue.replace(/-/, ""),
      };
      this.$api
        .revenue({ method: "post", type: "getByEnCode" }, queryData)
        .then((res) => {
          var data = res.data.data;
          if(!flag){
            this.revenueList = [];
            this.revenueYSList = [];
            this.revenueList.push(
              { name: "用电量（度）", num: data.electric_cnt },
              { name: "电费（元）", num: data.electric_fee }
            );
            this.revenueYSList.push(
              { name: "去年年累计营收", num: data.total_year_revenue },
              { name: "主营业务营收", num: data.total_year_main_revenue },
              { name: "营业外收入", num: data.total_year_auxiliary_revenue },
              { name: "营业成本", num: data.year_busi_cost },
              { name: "营业外支出", num: data.year_non_busi_cost },
              { name: "其他", num: data.total_year_else_revenue }
            );
          }else if(flag == 1) {
            this.revenueList = [];
            this.revenueList.push(
              { name: "用电量（度）", num: data.electric_cnt },
              { name: "电费（元）", num: data.electric_fee }
            );
          }else{
            this.revenueYSList = [];
            this.revenueYSList.push(
              { name: "去年年累计营收", num: data.total_year_revenue },
              { name: "主营业务营收", num: data.total_year_main_revenue },
              { name: "营业外收入", num: data.total_year_auxiliary_revenue },
              { name: "营业成本", num: data.year_busi_cost },
              { name: "营业外支出", num: data.year_non_busi_cost },
              { name: "其他", num: data.total_year_else_revenue }
            );
          }
        });
    },
    // 税务信息
    getTax() {
      let queryData = {
        pageNo: 1,
        pageSize: 10000,
        // enterpriseId: this.id,
        enCode: this.qyObj.credit_no,
        date: this.taxDateValue.replace(/-/, ""),
      };
      this.$api
        .revenue({ method: "post", type: "getByEnCode" }, queryData)
        .then((res) => {
          var data = res.data.data;
          this.taxList = [];
          this.taxList.push(
            { name: "税收总额", num: data.total_year_tax },
            { name: "增值税", num: data.total_year_vat },
            { name: "消费税", num: data.total_year_excise_tax },
            {
              name: "个人所得税",
              num: data.total_year_people_income_tax,
            },
            {
              name: "企业所得税",
              num: data.total_year_company_income_tax,
            },
            { name: "其他", num: data.total_year_else_tax }
          );
        });
    },
    dateConfirm(time) {
      this.revenueDateValue = formatDate("YY-MM", time);
      this.revenueDatetimePickerShowPicker = false;
      this.getRevenue(2);
    },
    taxDateConfirm(time) {
      this.taxDateValue = formatDate("YY-MM", time);
      this.taxDatetimePickerShowPicker = false;
      this.getTax();
    },
    yongnengDateConfirm(time) {
      this.yongnengDateValue = formatDate("YY-MM", time);
      this.yongnengDatetimePickerShowPicker = false;
      this.getRevenue(1);
    },
    getSettlement() {
      var data = {
        pageNo: 1,
        pageSize: 100,
        enterpriseId: this.id,
      };
      this.$api
        .spatialEnterprise({ method: "post", type: "datagrid" }, data)
        .then((res) => {
          let data = res.data.data;
          if (data.length < 1)
            return (this.settlementInfo = [
              { name: "场地名称", num: "" },
              { name: "场地类型", num: "" },
              { name: "场地位置", num: "" },
              {
                name: "租赁面积(平方米)",
                num: "",
              },
              {
                name: "面积单价(元/平方/天)",
                num: "",
              },
              {
                name: "开始时间",
                num: "",
              },
              {
                name: "结束时间",
                num: "",
              },
            ]);
          data.forEach((item, index) => {
            this.settlementInfo.push(
              { name: "序号", num: index + 1 },
              { name: "场地名称", num: item.spatialName },
              { name: "场地类型", num: item.spatialType },
              { name: "场地位置", num: item.spatialAddress },
              {
                name: "租赁面积(平方米)",
                num: item.rentArea,
              },
              {
                name: "面积单价(元/平方/天)",
                num: item.spatialUnitPrice,
              },
              {
                name: "开始时间",
                num: item.startTime,
              },
              {
                name: "结束时间",
                num: item.endTime,
              }
            );
          });
        });
    },
  },
  computed: {
    permissList() {
      return JSON.parse(sessionStorage.getItem("user")).permiss;
    },
  },
};
</script>

<style scoped lang="less">
.title {
  padding: 10px 16px;
}
.table {
  border: 0px solid darkgray;
}
.tr {
  color: #000;
  display: flex;
  width: 100%;
  justify-content: center;
  padding: 5px 0;
  align-items: center;
}
.td:nth-child(1) {
  width: 30%;
  justify-content: center;
  text-align: center;
}
.td:nth-child(2) {
  width: 60%;
  justify-content: center;
  text-align: center;
}
.bg-w {
  background: snow;
}
.bg-g {
  background: #e6f3f9;
}
.th {
  width: 40%;
  justify-content: center;
  background: #49a9ee;
  color: #fff;
  display: flex;
  height: 30px;
  align-items: center;
}
.tag {
  background: rgb(228, 31, 31);
  padding: 3px 5px;
  border-radius: 3px;
  color: #fff;
}
.tag1 {
  background: rgba(0, 194, 151, 0.8);
}
.tag2 {
  background: rgba(203, 222, 115, 0.9);
}
.tag3 {
  background: rgba(210, 180, 140, 0.8);
}
.tag4 {
  background: rgba(160, 198, 232, 0.9);
}
</style>
